# _*_ encoding:utf-8 _*_

import sqlite3
import os
import sys


from sqlalchemy import create_engine

from sqlalchemy.orm import sessionmaker

from sqlalchemy import Column, Integer, String

from sqlalchemy.ext.declarative import declarative_base

engine = create_engine('sqlite:///treta.db')

Base = declarative_base()

class Aluno(Base):

    __tablename__ = 'alunos'
    
    id = Column(Integer, primary_Key=True )
    
    nome = Column(String)
    
    numero = Column(Integer)
    
    curso = Column(String)
    
    def __init__(self, nome, numero, curso):
		
    
        self.nome = nome
        
        self.numero = numero
        
        self.curso = curso
        
Base.metadata.create_all(engine)
    
Session = sessionmaker(bind=engine)

session = Session()

aluno1 = Aluno('Tiago Bond', '007', 'Espeologia')

aluno2 = Aluno('Barbara Bond', '008', 'Comunicacoes')

aluno3 = Aluno('Manuel Bod', '009', 'Filosofia')

session.add(aluno1); session.add(aluno2); session.add(aluno3)

session.commit()

for obj in session.query(Aluno):
	
	print obj.nome
	
print

for obj in session.query(Aluno).filter(Aluno.nome=='Barbara Bond'):
	print obj.nome, obj.numero, obj.curso
	
